import request from '@/utils/request';

// 封装请求获取课程数据
export const fetchCourses = async (teacherId) => {
    try {
        const response = await request.get('/teacher/GetCourses', {
            params: { teacherId }
        });
        if (response.data && Array.isArray(response.data.courses) && response.data.courses.length > 0) {
            const courses = response.data.courses;
            console.log(courses);
            return courses;
        } else {
            throw new Error('未找到课程数据');
        }
    } catch (error) {
        console.error('请求失败:', error.message || error);
        throw new Error('获取课程数据失败');
    }
};
